package com.tiger.web.controller.communal;

import com.tiger.common.annotation.Log;
import com.tiger.common.core.controller.BaseController;
import com.tiger.common.core.domain.AjaxResult;
import com.tiger.common.core.page.TableDataInfo;
import com.tiger.common.enums.BusinessType;
import com.tiger.common.utils.DateUtils;
import com.tiger.communal.domain.HydropowerSubmeterAlter;
import com.tiger.communal.service.IHydropowerSubmeterAlterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.util.List;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 水电分历史Controller
 *
 * @author standard
 * @date 2022-10-14
 */
@Api(tags = "水电分历史")
@RestController
@RequestMapping("/system/alter")
public class HydropowerSubmeterAlterController extends BaseController {
    @Autowired
    private IHydropowerSubmeterAlterService hydropowerSubmeterAlterService;

    /**
     * 查询水电分历史列表
     */
    @ApiOperation(value = "查询水电分历史列表")
    //@PreAuthorize("@ss.hasPermi('system:alter:list')")
    @GetMapping("/list")
    public TableDataInfo list(HydropowerSubmeterAlter hydropowerSubmeterAlter) {
        startPage();
        List<HydropowerSubmeterAlter> list = hydropowerSubmeterAlterService.selectHydropowerSubmeterAlterList(hydropowerSubmeterAlter);
        return getDataTable(list);
    }


    /**
     * 获取水电分历史详细信息
     */
    @ApiOperation(value = "获取水电分历史列详细信息")
    //@PreAuthorize("@ss.hasPermi('system:alter:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(hydropowerSubmeterAlterService.selectHydropowerSubmeterAlterById(id));
    }

    /**
     * 新增水电分历史
     */
    @ApiOperation(value = "抄表")
    //@PreAuthorize("@ss.hasPermi('system:alter:add')")
//    @Log(title = "水电分历史", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody HydropowerSubmeterAlter hydropowerSubmeterAlter) {
        hydropowerSubmeterAlter.setCreatedAt(DateUtils.getNowDate());
        return toAjax(hydropowerSubmeterAlterService.insertHydropowerSubmeterAlter(hydropowerSubmeterAlter));
    }

    /**
     * 修改水电分历史
     */
    @ApiOperation(value = "修改水电分历史")
    //@PreAuthorize("@ss.hasPermi('system:alter:edit')")
//    @Log(title = "水电分历史", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody HydropowerSubmeterAlter hydropowerSubmeterAlter) {
        return toAjax(hydropowerSubmeterAlterService.updateHydropowerSubmeterAlter(hydropowerSubmeterAlter));
    }

    /**
     * 删除水电分历史
     */
    @ApiOperation(value = "删除水电分历史")
    //@PreAuthorize("@ss.hasPermi('system:alter:remove')")
//    @Log(title = "水电分历史", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(hydropowerSubmeterAlterService.deleteHydropowerSubmeterAlterByIds(ids));
    }
}
